package com.example.schooljava.service.impl;

import com.example.schooljava.pojo.entity.UserRole;
import com.example.schooljava.mapper.UserRoleMapper;
import com.example.schooljava.service.UserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.schooljava.util.Result;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LDH
 * @since 2022/08/13
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {

    @Override
    public Result setUserRole(UserRole userRole) {
        save(userRole);
        return new Result<>().OK(true,"设置用户身份成功");
    }

    @Override
    public Result delUserRole(ArrayList<String> list) {
        for (String l : list) {
            for (UserRole userRole : list()) {
                if (Long.parseLong(l) == userRole.getId())
                    removeById(Long.parseLong(l));
            }
        }
        return new Result<>().OK(true,"删除用户身份成功");
    }
}
